package com.whg.demo.biz.schedule;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;
import java.util.concurrent.TimeUnit;

/**
 * @Author whg
 * @create 2022/12/9 9:22
 * @description：
 */
//@Component
public class TestSchedule {

    /**
     * fixedRate间隔时间，距离上一个任务开始的间隔时间，单位毫秒
     */
    //@Scheduled(fixedRate = 2000)
    //@Scheduled(cron = "*/2 * * * * *")
    @Scheduled(fixedDelayString = "${schedule.time}")
    public void test() throws InterruptedException {
        TimeUnit.SECONDS.sleep(4);
        System.out.println("当前时间：" + LocalDateTime.now());
    }

}
